Skip to content

fix(auth): write version field in credentials.json for grounds-push compat#16

Merged
hbrombeer merged 1 commit intomainfrom
fix/credentials-version-field
Apr 29, 2026
Merged

fix(auth): write version field in credentials.json for grounds-push compat#16
hbrombeer merged 1 commit intomainfrom
fix/credentials-version-field

Conversation

@hbrombeer
Copy link
Copy Markdown
Member

Summary

`grounds push` was failing for users with credentials.json files written by the CLI:

```

Task :groundsPush FAILED
Failed to parse credentials file at ~/.config/grounds/credentials.json:
Field 'version' is required for type with serial name
'gg.grounds.push.client.CredentialsFile', but it was missing at path: $
```

Root cause: The Gradle plugin's `CredentialResolver` (grounds-push) requires `version: 1`, but the CLI's `Credentials` struct never had a `version` field — schemas drifted because both were created in single-shot commits and never cross-synced.

Fix

  • Add `Version int` field to `Credentials`; `CredentialsVersion = 1`.
  • `Marshal()` always sets `Version = CredentialsVersion` so callers can't forget.
  • `ParseCredentials()` silently upgrades pre-version files (`version: 0` after parse → bumped to 1). They get re-written with the correct version on the next refresh/login.

Test plan

  • `go test ./internal/auth/...` passes
  • New tests verify Marshal always writes `version: 1`
  • New tests verify legacy files (no `version` field) parse and upgrade
  • After upgrade, `grounds login` produces a credentials.json that `grounds push` can read
  • User with existing credentials can either re-login OR add `"version": 1,` manually as a one-time migration

Cross-repo contract: must stay in lockstep with `grounds-push` `plugin/src/main/kotlin/gg/grounds/push/client/CredentialResolver.kt`. Both files now reference each other in their doc comments.

🤖 Generated with Claude Code

…ompat

The Gradle plugin (grounds-push CredentialResolver) requires a 'version: 1'
field but the CLI never wrote one, causing 'grounds push' to fail with:

  Failed to parse credentials file ... Field 'version' is required for
  type with serial name 'gg.grounds.push.client.CredentialsFile'

Fix:
- Add Version field to Credentials struct, always 1 on Marshal
- ParseCredentials silently upgrades legacy (version=0) files to v1;
  they get re-written with the correct version on next refresh/login

Cross-repo contract: must stay in lockstep with grounds-push
plugin/src/main/kotlin/gg/grounds/push/client/CredentialResolver.kt.
@hbrombeer hbrombeer merged commit 78839a1 into main Apr 29, 2026
5 checks passed
@hbrombeer hbrombeer deleted the fix/credentials-version-field branch April 29, 2026 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant